﻿using System;
using System.ComponentModel.DataAnnotations;

namespace AutoClub.Core
{
    public abstract class LookupValue<T> : BaseEntity<int>
    {

        #region Properties

        [Required]
        public override int Id
        {
            get
            {
                return Convert.ToInt32(this.Value as Enum);
            }
            internal set
            {
                this.Value = (T)Enum.ToObject(typeof(T), value);
            }
        }

        [Required]
        public string Description { get; set; }

        [Required]
        public T Value { get; set; }

        #endregion

        #region Constructor

        public LookupValue(T value)
            : this()
        {
            this.Value = value;
        }

        public LookupValue()
        {

        }

        #endregion
    }
}
